import java.util.Arrays;

/**
 * @program: LeetCode
 * @description: LeetCode : 452. 用最少数量的箭引爆气球
 * @author: WXY
 * @create: 2023-01-23 09:56
 * @Version 1.0
 **/
public class Num452_findMinArrowShots {
    public static int findMinArrowShots(int[][] points) {
        Arrays.sort(points, (a, b) -> Integer.compare(a[0], b[0]));
        int ans  = 1;
        int end = points[0][1];
        for (int i = 1; i < points.length; i++) {
            if (points[i][0] > end) {
                ans++;
                end = points[i][1];
            } else {
                end = Math.min(end, points[i][1]);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        int[][] arr = {{-2147483646,-2147483645}, {2147483646,2147483647}};
        int minArrowShots = findMinArrowShots(arr);
        System.out.println(minArrowShots);
    }
}
